package cn.zxl.spring.holiday.job.util;

import cn.zxl.spring.holiday.job.domain.Department;
import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.property.ExcelContentProperty;

/**
 * @Date 2021/10/7 22:10
 * @Version 1.0
 * @Description
 */
public class EmployeeConverter implements Converter<Department> {
    @Override
    public Class supportJavaTypeKey() {
        return Department.class;
    }

    @Override
    public CellDataTypeEnum supportExcelTypeKey() {
        return CellDataTypeEnum.STRING;
    }

    @Override
    public Department convertToJavaData(CellData cellData, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) throws Exception {
        Department department = new Department();
        department.setName(cellData.getStringValue());
        return department;
    }

    @Override
    public CellData convertToExcelData(Department department, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) throws Exception {
        return new CellData(department.getName());
    }
}
